/**
 * 
 */
package com.swg.cocobox;

import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;

/**
 * Simple class to handle the changes of a {@link SelectionKey} associated with a {@link SocketChannel}
 * @author satriaprayoga
 *
 */
public class KeyChange {

	/**
	 * flag for operation registration of {@link SelectionKey}
	 */
	public static final int REGISTER=1;
	/**
	 * flag for operation change of {@link SelectionKey}
	 */
	public static final int CHANGE=2;
	
	private SocketChannel channel;
	private int operation;
	private int type;
	
	/**
	 * Constructor for {@link KeyChange} instance
	 * @param channel {@linkplain SocketChannel} accessed throug {@link SelectionKey}
	 * @param type type of {@link SelectionKey} changeable operation, {@link KeyChange#REGISTER} to register new
	 * and {@link KeyChange#CHANGE} to change operation {@link SelectionKey}
	 * @param ops valid operation of {@link SelectionKey}: {@link SelectionKey#OP_ACCEPT}, {@link SelectionKey#OP_CONNECT}, 
	 * {@link SelectionKey#OP_READ},{@link SelectionKey#OP_WRITE}
	 */
	public KeyChange(SocketChannel channel, int type, int ops) {
		this.channel = channel;
		this.operation = ops;
		this.type = type;
	}
	
	
	public SocketChannel getChannel() {
		return channel;
	}
	public int getOperation() {
		return operation;
	}
	public int getType() {
		return type;
	}

}
